import { useState } from 'nuxt/app'
import { readonly } from 'vue'

export const useToken = () => {
  const token = useState<string>('token', () => '')

  const setToken = (newToken: string) => {
    token.value = newToken
  }

  const clearToken = () => {
    token.value = ''
  }

  return {
    token: readonly(token),
    setToken,
    clearToken
  }
}
